﻿//************************************************************ 
// Copyright © 2009 - 2010 Oleg Stuhin & Rostislav Haitovich
// To learn more about Mytrip.Mvc.Entyty visit 
// http://starterkitmytripmvc.codeplex.com/
// mytripmvc@gmail.com
// license: Microsoft Public License (Ms-PL) 
// ***********************************************************
using System.Text;
using System.Web.Mvc;

namespace Mytrip.Users
{
    /// <summary>
    /// Captcha Helper
    /// </summary>
    public static class CaptchaHelper
    {
        /// <summary>
        /// Captcha Image
        /// </summary>
        /// <param name="helper">HtmlHelper</param>
        /// <param name="width">width</param>
        /// <param name="height">height</param>
        /// <param name="fontfamily">fontfamily</param>
        /// <returns>static string</returns>
        public static string CaptchaImage(this HtmlHelper helper, int width, int height, string fontfamily)
        {
            StringBuilder result = new StringBuilder();
            TagBuilder imgCaptcha = new TagBuilder("img");
            imgCaptcha.MergeAttribute("src", "/Content/images/empty.gif");
            imgCaptcha.MergeAttribute("alt", "Captcha");
            imgCaptcha.AddCssClass("captcha");
            imgCaptcha.MergeAttribute("style", "width: " + width + "px; height: " + height + "px; background-image:url('/Captcha/Index/" + width + "/" + height + "/" + fontfamily + "');");
            result.AppendLine(imgCaptcha.ToString());
            return result.ToString();
        }
    }
}